//
//  FZLogInViewController.m
//  oo
//
//  Created by apple on 2017/10/12.
//  Copyright © 2017年 apple. All rights reserved.
//

#import "FZLogInViewController.h"
#import "FZPasswordViewController.h"
#import "FZRegisterStrViewController.h"


@interface FZLogInViewController ()<UITextFieldDelegate>

@property (weak, nonatomic) IBOutlet UITextField *phoneTextField;
@property (weak, nonatomic) IBOutlet UITextField *passwordTextField;
@property (weak, nonatomic) IBOutlet UILabel *passwordLabel;
@property (weak, nonatomic) IBOutlet UILabel *registerStrLabel;
@property (weak, nonatomic) IBOutlet UIButton *logInBtn;
@property (weak, nonatomic) IBOutlet UILabel *otherLab;
@property (weak, nonatomic) IBOutlet UIImageView *eyeImg;
@end

@implementation FZLogInViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    
    
    NSDictionary *passwordAttribtDic = @{NSUnderlineStyleAttributeName: [NSNumber numberWithInteger:NSUnderlineStyleSingle]};
    NSMutableAttributedString *passwordAttribtStr = [[NSMutableAttributedString alloc]initWithString:@"忘记密码?" attributes:passwordAttribtDic];
    _passwordLabel.attributedText = passwordAttribtStr;
    
    
    _phoneTextField.delegate = self;
     [_phoneTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    
    _passwordTextField.delegate = self;
    [_passwordTextField addTarget:self action:@selector(textFieldDidChange:) forControlEvents:UIControlEventEditingChanged];
    
    UITapGestureRecognizer *passwordTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(passwordMothed)];
    [_passwordLabel addGestureRecognizer:passwordTap];
    
    UITapGestureRecognizer *registerStrTap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(registerStrMothed)];
    [_registerStrLabel addGestureRecognizer:registerStrTap];
}

-(BOOL)textFieldShouldReturn:(UITextField *)textField{
    
    [_phoneTextField resignFirstResponder];
    [_passwordTextField resignFirstResponder];
    return YES;
}

- (void)textFieldDidChange:(UITextField *)textField{
    if (textField == _phoneTextField) {
        if (_phoneTextField.text.length > 11) {
            
        }
    }else{
        if (_phoneTextField.text.length != 11) {
            
        }else{
            if (_phoneTextField.text.length && (_passwordTextField.text.length > 6||_passwordTextField.text.length < 20)) {
                _logInBtn.backgroundColor = [UIColor orangeColor];
            }
        }
    }
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)logInSelected:(UIButton *)sender {
    
}
- (IBAction)otherSelected:(UIButton *)sender {
    
}

-(void)registerStrMothed{
    [self.navigationController pushViewController:[FZRegisterStrViewController new] animated:YES];
}
-(void)passwordMothed{
    [self.navigationController pushViewController:[FZPasswordViewController new] animated:YES];
}

-(void)viewWillAppear:(BOOL)animated{
    [super viewWillAppear:animated];
    self.navigationController.navigationBar.hidden = YES;
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;
}
-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBar.hidden = YES;
}

@end
